<?php
namespace app\admin\model;
use think\Model;
use think\Db;
class OrderShop extends Model
{
    protected $pk = 'id';
    protected $table = 'sdb_order_shop';
    public function goods()
    {
        return $this->hasOne('Shop','id','shop_id');
    }

    /**
     * 订单首页搜索商品的shop_num和
     * @param OrderShop $orderShop
     */
    public function searchShopNumSum($order_number)
    {
        return Db::table('sdb_order_shop')->where('order_number',$order_number)
             ->field('order_number,sum(shop_num) as numTotal')
             ->group('order_number')
             ->select();
    }

    /**
     *  订单提醒发货页面搜索商品的shop_num和
     * @param $order_number
     * @return false|\PDOStatement|string|\think\Collection
     */
    public function searchRemindShopNumSum($order_number)
    {
        return Db::table('sdb_order_shop')->where('order_number',$order_number)
            ->field('order_number,sum(shop_num) as numTotal,shop_name')
            ->group('order_number')
            ->select();
    }
    public function searchRefundShopNumSum($order_number){
        return Db::table('sdb_order_shop')->where('order_number',$order_number)
            ->field('order_number,sum(shop_num) as numTotal,shop_name')
            ->group('order_number')
            ->select();
    }
}
